import 'package:flutter/material.dart';

import '../../providers/local_shared_cache.dart';
import '../login/reset_password_page.dart';

class AccountSettingPage extends StatefulWidget {
  const AccountSettingPage({super.key});

  @override
  State<AccountSettingPage> createState() => _AccountSettingPageState();
}

class _AccountSettingPageState extends State<AccountSettingPage> {
  TextStyle? _textStyleDefault = TextStyle(fontSize: 20);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('账号与安全'),
      ),
      body: ListView(
        children: [
          ListTile(
            title: Text(
              '手机号',
              style: _textStyleDefault,
            ),
            trailing: const Wrap(
              crossAxisAlignment: WrapCrossAlignment.center,
              children: [
                Text(
                  "188***45",
                  style: TextStyle(fontSize: 16, color: Colors.black45),
                ),
                Image(
                  color: Colors.black45,
                  image: AssetImage("images/arrow_right_icon.png"),
                  width: 20,
                )
              ],
            ),
            splashColor: Colors.black,
          ),
          ListTile(
            title: Text(
              '密码',
              style: _textStyleDefault,
            ),
            trailing: const Wrap(
              crossAxisAlignment: WrapCrossAlignment.center,
              children: [
                Text(
                  "*****",
                  style: TextStyle(fontSize: 16, color: Colors.black45),
                ),
                Image(
                  color: Colors.black45,
                  image: AssetImage("images/arrow_right_icon.png"),
                  width: 20,
                )
              ],
            ),
            splashColor: Colors.black,
            onTap: () {
              Navigator.push(context,
                  MaterialPageRoute(builder: (_) => RestPasswordPage()));
            },
          ),
          ListTile(
            title: Text(
              '实名认证',
              style: _textStyleDefault,
            ),
            trailing: const Wrap(
              crossAxisAlignment: WrapCrossAlignment.center,
              children: [
                Text(
                  "未认证",
                  style: TextStyle(fontSize: 16, color: Colors.black45),
                ),
                Image(
                  color: Colors.black45,
                  image: AssetImage("images/arrow_right_icon.png"),
                  width: 20,
                )
              ],
            ),
            splashColor: Colors.black,
          ),
          Container(
            height: 40,
            child: Text(
              '绑定信息',
              style: TextStyle(fontSize: 16, color: Colors.black45),
            ),
            margin: EdgeInsets.symmetric(horizontal: 20),
          ),
          ListTile(
            title: Text(
              '微信账号',
              style: _textStyleDefault,
            ),
            trailing: const Wrap(
              crossAxisAlignment: WrapCrossAlignment.center,
              children: [
                Text(
                  "Jacee",
                  style: TextStyle(fontSize: 16, color: Colors.black45),
                ),
                Image(
                  color: Colors.black45,
                  image: AssetImage("images/arrow_right_icon.png"),
                  width: 20,
                )
              ],
            ),
            splashColor: Colors.black,
          ),
          ListTile(
            title: Text(
              '微博账号',
              style: _textStyleDefault,
            ),
            trailing: const Wrap(
              crossAxisAlignment: WrapCrossAlignment.center,
              children: [
                Text(
                  "未绑定",
                  style: TextStyle(fontSize: 16, color: Colors.black45),
                ),
                Image(
                  color: Colors.black45,
                  image: AssetImage("images/arrow_right_icon.png"),
                  width: 20,
                )
              ],
            ),
            splashColor: Colors.black,
          ),
          ListTile(
            title: Text(
              'QQ账号',
              style: _textStyleDefault,
            ),
            trailing: const Wrap(
              crossAxisAlignment: WrapCrossAlignment.center,
              children: [
                Text(
                  "未绑定",
                  style: TextStyle(fontSize: 16, color: Colors.black45),
                ),
                Image(
                  color: Colors.black45,
                  image: AssetImage("images/arrow_right_icon.png"),
                  width: 20,
                )
              ],
            ),
            splashColor: Colors.black,
          ),
          SizedBox(
            height: 40,
          ),
          FilledButton(
              style: ButtonStyle(
                  backgroundColor: MaterialStateProperty.all(Colors.white),
                  foregroundColor: MaterialStateProperty.all(Colors.black45),
                  padding: MaterialStateProperty.all(EdgeInsets.zero)),
              onPressed: () => _logout(),
              child: const Text(
                '退出登录',
                style: TextStyle(fontSize: 20),
              )),
          FilledButton(
              style: ButtonStyle(
                  backgroundColor: MaterialStateProperty.all(Colors.white),
                  foregroundColor: MaterialStateProperty.all(Colors.redAccent),
                  padding: MaterialStateProperty.all(EdgeInsets.zero)),
              onPressed: () {},
              child: const Text(
                '注销账号',
                style: TextStyle(fontSize: 20, color: Colors.red),
              )),
        ],
      ),
    );
  }

  _logout() async {
    Navigator.pushNamedAndRemoveUntil(context, '/', (_) => false);
    await LocalSharedCache.removeString("loginUid");
  }
}
